#import "HomeworkViewController.h"
#import "CellStyleHomework.h"
#import "ModalViewController.h"
#import "HomeworkTableViewCell.h"
#import "UserDao.h"
#import "JsonUtil.h"
#import "PopUIManager.h"
#import "NetWorkManager.h"
#import "UIUtils.h"
#import "MJRefresh.h"
#import "MBProgressHUD.h"
#import "HomeworkCalendarViewController.h"
#import "Masonry.h"
#import "SMViewController.h"
#import "JoinClassViewController.h"

@interface HomeworkViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (retain, nonatomic) UITableView *tableView;
@property (nonatomic, retain) MBProgressHUD *hud;
//@property (nonatomic, retain) IBOutlet UIImageView *navView;
@property (nonatomic, retain) UIButton *rightButton;


@property (nonatomic, retain) NSMutableArray *data;
@property (nonatomic, assign) BOOL isDataLoading;
@property (nonatomic, copy) NSString *cacheListDataPath;
@property (nonatomic, assign) NSInteger minOrder;
@property (nonatomic, assign) NSInteger currentTag;
@property BOOL is_first;
@property UIView *notips;

@property (nonatomic, copy) void (^centerNavBlock)(NSInteger);

@end

@implementation HomeworkViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    
    // Do any additional setup after loading the view from its nib.
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, APP_SCREEN_WIDTH, APP_SCREEN_HEIGHT - 49) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableView];
    self.minOrder = 0;
    self.isDataLoading = NO;
    self.currentTag = 1;
    self.cacheListDataPath = [HomeDirectory stringByAppendingString:@"homeworkListData.plist"];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_btn_left"] style:UIBarButtonItemStylePlain target:self action:@selector(leftButtonClick:)];
    
    _rightButton = [[UIButton alloc] initWithFrame:CGRectMake(APP_SCREEN_WIDTH - 30, 32, 19, 19)];
    [_rightButton setImage:[UIImage imageNamed:@"homework_btn_calendar"] forState:UIControlStateNormal];
    _rightButton.backgroundColor = [UIColor clearColor];
    [_rightButton addTarget:self action:@selector(rightButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    //[_navView addSubview:_rightButton];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_rightButton];
    
    WS(weakSelf);
    UIView *titleView = [self createNavCenterSilderWithNames:@[@"亲子作业",@"阶梯练习"]
                                       withBlock:^(NSInteger index){
                                           __strong typeof (weakSelf) strongSelf = weakSelf;
                                           if (!strongSelf || _currentTag == index) {
                                               return;
                                           }
                                           
                                           _currentTag = index;
                                           NSLog(@"tag:%ld", (long)_currentTag);
                                           if(_currentTag ==1){
                                               _tableView.hidden = NO;
                                              
                                           }else{
                                               _tableView.hidden = YES;
                                                [[PopUIManager getInstanse]popAlertView:nil title:@"提示" message:@"暂无作业" cancelButtonTitle:@"确定"];
                                           }
                                       }isWider:YES];
    
    self.navigationItem.titleView = titleView;
    
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
                                   initWithTitle:@""
                                   style:UIBarButtonItemStylePlain
                                   target:nil
                                   action:nil];
    self.navigationItem.backBarButtonItem=backButton;
    
    [self _initData];
    [self initNoTips];
    _is_first = YES;
}

#pragma mark - Data

- (void)_initData {

    [self loadLocalData];
    
    [self setUpRefreshPlugin];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if(_is_first){
        _is_first = NO;
    }else{
        [self headerRereshing];
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

-(void)initNoTips
{
    _notips = [[UIView alloc]initWithFrame:CGRectMake(0, 100, APP_SCREEN_WIDTH, 100)];
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake((APP_SCREEN_WIDTH-120)/2, 0, 120, 15)];
    label1.textColor = UIColorMake(45, 45, 45);
    label1.text = @"你还没有班级动态";
    label1.font = [UIFont systemFontOfSize:15];
    label1.textAlignment = NSTextAlignmentCenter;
    [_notips addSubview:label1];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake((APP_SCREEN_WIDTH-260)/2, 20, 260, 15)];
    label2.textColor = UIColorMake(180, 180, 180);
    label2.text = @"赶紧加入班级就可以看到动态啦！";
    label2.font = [UIFont systemFontOfSize:15];
    label2.textAlignment = NSTextAlignmentCenter;
    [_notips addSubview:label2];
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake((APP_SCREEN_WIDTH-120)/2, 50, 100, 30)];
    [button setTitle:@"加入班级" forState:UIControlStateNormal];
    [button setTintColor:[UIColor whiteColor]];
    [button setBackgroundColor:UIColorMake(252, 74, 74)];
    [button addTarget:self action:@selector(addClass:) forControlEvents:UIControlEventTouchUpInside];
    button.layer.cornerRadius = 3.0;
    [_notips addSubview:button];
    [self.view addSubview:_notips];
    _notips.hidden = YES;
}
-(void)addClass:(id)sender
{
    JoinClassViewController *joinClass = [[JoinClassViewController alloc]init];
    BabyInfo *baby = [[UserDao getInstance]getCurrentBaby];
    joinClass.babyid = baby.cid;
    [self.navigationController pushViewController:joinClass animated:YES];
}
/**
 *  集成刷新控件
 */
#pragma mark - MJRefresh

- (void)setUpRefreshPlugin {
    
    // 1.下拉刷新(进入刷新状态就会调用self的headerRereshing)
    [_tableView addHeaderWithTarget:self action:@selector(headerRereshing)];
    //#warning 自动刷新(一进入程序就下拉刷新)
    [_tableView headerBeginRefreshing];
    
    // 2.上拉加载更多(进入刷新状态就会调用self的footerRereshing)
    [_tableView addFooterWithTarget:self action:@selector(footerRereshing)];
    
    //设置文字(也可以不设置,默认的文字在MJRefreshConst中修改)
    _tableView.headerPullToRefreshText = @"下拉刷新";
    _tableView.headerReleaseToRefreshText = @"松开刷新";
    _tableView.headerRefreshingText = @"正在刷新...";
    
    _tableView.footerPullToRefreshText = @"上拉加载";
    _tableView.footerReleaseToRefreshText = @"松开加载";
    _tableView.footerRefreshingText = @"正在加载...";
}

- (void)startHeaderRefresh{
    //刷新
    [_tableView headerBeginRefreshing];
}

//================顶部刷新，获取最新动态=========================
//首次进入会自动执行一次获取最新动态
- (void)headerRereshing
{
    if (_isDataLoading) {
        return;
    }

    if ([NetWorkManager connectedToNetwork]) {
        _minOrder = 0;
        _isDataLoading = YES;
        [self apiGetDynamicMessage:@"new" baseId:@"-1"];
    }else{
        //没有网络的情况下，加载本地缓存数据
        [self loadLocalData];
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"网络连接断开" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
    }
}

//================底部刷新，获取最新动态=========================
- (void)footerRereshing
{
    
    if([NetWorkManager connectedToNetwork]) {

        //当服务器获取到数据时，回调方法setOldDataWithDict
        if (_minOrder <= 1) {
            [self stopFooterRefresh];
            [self ShowExclaHud:@"已加载所有作业"];
            return;
        }
        NSInteger newOrder = _minOrder - 2;
        _minOrder = newOrder >= 1 ? newOrder : 1;
        [self apiGetDynamicMessage:@"old" baseId:@"-1"];
    }else{
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"网络连接断开" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
    }
}

-(void) stopHeaderRefresh {
    
    _isDataLoading = NO;
    [self.tableView headerEndRefreshing];
}

-(void) stopFooterRefresh {
    
    _isDataLoading = NO;
    [self.tableView footerEndRefreshing];
}

#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return 38.0f;
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, APP_SCREEN_WIDTH, 38)];
    view.backgroundColor = UIColorMake(244, 244, 244);
    
    UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, view.frame.size.width - 15, view.frame.size.height)];
    title.backgroundColor = [UIColor clearColor];
    title.font = [UIFont systemFontOfSize:15.0f];
    title.textColor = UIColorMake(151, 151, 151);
    title.text = _data[section][@"sectionTitle"];
    [view addSubview:title];
    
    return view;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *CellIdentifier = @"CellStyleHomework";
    
    HomeworkTableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil) {
        cell = [[HomeworkTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.backgroundColor = [UIColor whiteColor];
    }
    
    cell.data = _data[indexPath.section][@"plugins"][indexPath.row];
    cell.picPrefix = _data[indexPath.section][@"picPrefix"];

    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%@",indexPath);
    //该方法响应列表中行的点击事件
//    NSInteger section = indexPath.section;
//    NSInteger row = indexPath.row;
    //点击后弹出该对话框。
    [tableView deselectRowAtIndexPath:indexPath animated:true];
    //更新当前点击的行的信息
    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _data.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [_data[section][@"plugins"] count];
}

//设置Cell行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 92;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)syncUiWithoutHomework {
    UIImageView *default_img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    default_img.center = CGPointMake(APP_SCREEN_WIDTH/2, APP_SCREEN_HEIGHT/2-40);
    [default_img setImage:[UIImage imageNamed:@"default_img"]];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, APP_SCREEN_WIDTH, 30)];
    [label setText:@"还没有布置作业哦"];
    [label setTextColor:UIColorMake(200, 200, 200)];
    [label setFont:[UIFont systemFontOfSize:14]];
    label.textAlignment = NSTextAlignmentCenter;
    label.center = CGPointMake(APP_SCREEN_WIDTH/2, default_img.bottom+20);
    [self.view addSubview:label];
    
    [self.view addSubview:default_img];
}

#pragma mark - MBHub

- (void)showHudComplete:(NSString *)title success:(BOOL)success {
    NSString *name = success ? @"success" : @"excla";
    _hud.dimBackground = NO;
    _hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:name]];
    _hud.mode = MBProgressHUDModeCustomView;
    if(title.length > 0) {
        _hud.labelText = title;
    }
    [_hud hide:YES afterDelay:1];
}

- (void)ShowExclaHud:(NSString *)title {
    
    if (!_hud) {
        _hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];        
    }
    [self showHudComplete:title success:NO];
}

#pragma mark - Networking

-(BOOL)apiGetDynamicMessage:(NSString*)requestType baseId:(NSString *)base_id{
    
    NSUInteger classid = [[UserDao getInstance]getCurrentBaby].classid;
    if(classid>0){
        
            _notips.hidden = YES;
        
    }else{
        debugLog(@"未加入班级");
        _notips.hidden = NO;
        [self stopHeaderRefresh];
        [_data removeAllObjects];
        [_tableView reloadData];
        return NO;
    }
    NSString* uid = [NSString stringWithFormat:@"%ld",[[UserDao getInstance] getUserId]];
    NSString* utype = @"1";
    
    NSDictionary *temp_dict = @{@"uid":uid,
                                @"utype":utype,
                                @"token":[[UserDao getInstance]getAccessToken],
                                @"classid":@(classid),
                                @"dir":requestType,
                                @"min_order":@(_minOrder)};
    
    NSString *dataString = [JsonUtil convertDictionaryToJson:temp_dict];
    
    NSString *msg = @"PARENT_GET_HOMEWORK_LIST";
    
    PopUIManager *popUIMgr = [PopUIManager getInstanse];
    [popUIMgr showWaitingUI:self.view];
    
    [[NetWorkManager getInstanse] requestURLAsynMessage:msg data:dataString FinishBlock:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        
        if ([requestType isEqualToString:@"new"]) {
            [self stopHeaderRefresh];
        }else if ([requestType isEqualToString:@"old"]){
            [self stopFooterRefresh];
        }

        if (connectionError) { //连接失败
            NSLog(@"Http Error: %@   %ld", connectionError.localizedDescription,(long)connectionError.code);
            NSString *error_content = [NSString stringWithFormat:@"连接错误:%ld",(long)connectionError.code];
            [popUIMgr popAlertView:nil title:@"提示" message:error_content cancelButtonTitle:@"确定"];
        }else{//连接成功，判断是否有数据返回
            if (data) {
                NSDictionary *dict = [JsonUtil convertDataToDictionary:data];
                if ([[dict objectForKey:@"retCode"] integerValue]== 1) {
                    if ([requestType isEqualToString:@"new"]) { //下拉 获取最新数据的回调
                        [self dealData:dict isReload:YES];
                        [dict writeToFile:_cacheListDataPath atomically:YES];
                    }else if ([requestType isEqualToString:@"old"]){//上拉 加载更多旧数据的回调
                        [self dealData:dict isReload:NO];
                    }
                }else if ([[dict objectForKey:@"retCode"] integerValue]== 10020) {
                    [popUIMgr popAlertView:nil title:@"提示" message:@"暂时没有作业记录" cancelButtonTitle:@"确定"];
                }else{
//                    没有获取到作业
                    [self syncUiWithoutHomework];
                }
            }else{
                [popUIMgr popAlertView:nil title:@"提示" message:@"服务器没有返回数据" cancelButtonTitle:@"确定"];
            }
        }
        [popUIMgr removeWaitingUI];
        _isDataLoading = NO;
    }];
    return YES;
}

- (void)dealData:(NSDictionary *)dic isReload:(BOOL)reload {

    if (!dic || dic.count <=0 || ![dic isKindOfClass:[NSDictionary class]]) {
        return;
    }

    if (reload) {
        [_data removeAllObjects];
    }
    
    NSString *orderString = [NSString stringWithFormat:@"%@", dic[@"orders"]];
    NSArray *orders = [orderString componentsSeparatedByString:@","];
    if (orders && orders.count > 0) {
        _minOrder = [orders.lastObject integerValue];
    }else {
        _minOrder = 0;
    }
    
    NSDictionary *homeworks = dic[@"homeworks"];
    NSString *picPrefix = [NSString stringWithFormat:@"%@", dic[@"preurl"]];
    NSInteger todayStamp = [UIUtils todayStamp];
    
    for (int i = 1; i <= homeworks.count; i++) {
        NSDictionary *dic = [homeworks valueForKey:[NSString stringWithFormat:@"%d", i]];
        if (!dic) {
            break;
        }
        
        NSMutableDictionary *homeworkDic = [[NSMutableDictionary alloc] initWithDictionary:dic];
        [homeworkDic setObject:picPrefix forKey:@"picPrefix"];
        NSInteger stamp = [UIUtils stampFromDateString:homeworkDic[@"date"]];
        NSString *title = homeworkDic[@"date"];
        if (stamp == todayStamp) {
            title = @"今天";
        }else if (stamp == (todayStamp - 3600 * 24)) {
            title = @"昨天";
        }
        [homeworkDic setObject:title forKey:@"sectionTitle"];
        
        [_data addObject:homeworkDic];
    }
    
    [_tableView reloadData];
}

- (void)loadLocalData {

    if (_data) {
        [_data removeAllObjects];
    }else {
        _data = [[NSMutableArray alloc] init];
    }

    NSDictionary *cacheData = [[NSDictionary alloc] initWithContentsOfFile:_cacheListDataPath] ? : [[NSDictionary alloc] init];
    [self dealData:cacheData isReload:YES];
}

#pragma mark - NavCenterButton

- (UIView *)createNavCenterSilderWithNames:(NSArray *)names withBlock:(void (^)(NSInteger index))block isWider:(BOOL)wider
{
    NSInteger size = names.count;
    _centerNavBlock = block;
    if (size < 2) {
        return nil;
    }
    //13675135442 knshknsh
    float cellWidth = 61.0f;
    if (wider) {
        cellWidth = 91.0f;
    }
    float cellHeight = 24.0f;
    float width = cellWidth * size;
    float height = cellHeight + 2;
    if (size == 2) {
        width += 3;
    }else {
        width += 4;
    }
    
    int tag = 7000;
    UIView *backWrap = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
    [backWrap setBackgroundColor:[UIColor whiteColor]];
    [backWrap.layer setCornerRadius:3.0f];
    [backWrap.layer setMasksToBounds:YES];
    [backWrap setTag:tag];
    
    UIButton *buttonFirst = [[UIButton alloc] initWithFrame:CGRectMake(1, 1, cellWidth, cellHeight)];
    [buttonFirst setBackgroundColor:[UIColor whiteColor]];
    [buttonFirst setTitle:names[0] forState:UIControlStateNormal];
    [buttonFirst setTitleColor:DefaultNavigationColor forState:UIControlStateNormal];
    [buttonFirst setShowsTouchWhenHighlighted:YES];
    [buttonFirst setTag:++tag];
    [buttonFirst.titleLabel setFont:[UIFont systemFontOfSize:15.0f]];
    [buttonFirst addTarget:self action:@selector(centerNavClick:) forControlEvents:UIControlEventTouchUpInside];
    [backWrap addSubview:buttonFirst];
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:buttonFirst.bounds
                                                   byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft
                                                         cornerRadii:CGSizeMake(3, 3)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = buttonFirst.bounds;
    maskLayer.path = maskPath.CGPath;
    buttonFirst.layer.mask = maskLayer;
    
    if (size == 3) {
        UIButton *buttonMid = [[UIButton alloc] initWithFrame:CGRectMake(2 + cellWidth, 1, cellWidth, cellHeight)];
        [buttonMid setBackgroundColor:DefaultNavigationColor];
        [buttonMid setTitle:names[1] forState:UIControlStateNormal];
        [buttonMid setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [buttonMid setShowsTouchWhenHighlighted:YES];
        [buttonMid setTag:++tag];
        [buttonMid.titleLabel setFont:[UIFont systemFontOfSize:15.0f]];
        [buttonMid addTarget:self action:@selector(centerNavClick:) forControlEvents:UIControlEventTouchUpInside];
        [backWrap addSubview:buttonMid];
    }
    
    UIButton *buttonLast = [[UIButton alloc] initWithFrame:CGRectMake(1 + (cellWidth + 1) * (size - 1), 1, cellWidth, cellHeight)];
    [buttonLast setBackgroundColor:DefaultNavigationColor];
    [buttonLast setTitle:names[size - 1] forState:UIControlStateNormal];
    [buttonLast setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonLast setShowsTouchWhenHighlighted:YES];
    [buttonLast setTag:++tag];
    [buttonLast.titleLabel setFont:[UIFont systemFontOfSize:15.0f]];
    [buttonLast addTarget:self action:@selector(centerNavClick:) forControlEvents:UIControlEventTouchUpInside];
    [backWrap addSubview:buttonLast];
    UIBezierPath *maskPath2 = [UIBezierPath bezierPathWithRoundedRect:buttonLast.bounds
                                                    byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight
                                                          cornerRadii:CGSizeMake(3, 3)];
    CAShapeLayer *maskLayer2 = [[CAShapeLayer alloc] init];
    maskLayer2.frame = buttonLast.bounds;
    maskLayer2.path = maskPath2.CGPath;
    buttonLast.layer.mask = maskLayer2;
    
    return backWrap;
}

- (void)setCenterNavSelectIndex:(NSInteger)index
{
    NSInteger tag = index;
    if (tag < 1) {
        return;
    }
    
    UIView *wrap = self.navigationItem.titleView;
    if (!wrap) {
        return;
    }
    for (int i = 1; i <= wrap.subviews.count; i++) {
        UIButton *button = (UIButton *)[wrap viewWithTag:7000+i];
        if (tag == i) {
            [button setTitleColor:DefaultNavigationColor forState:UIControlStateNormal];
            [button setBackgroundColor:[UIColor whiteColor]];
        }else {
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [button setBackgroundColor:DefaultNavigationColor];
        }
    }
}

- (void)centerNavClick:(UIButton *)button
{
    NSInteger tag = button.tag - 7000;
    if (tag < 1) {
        return;
    }
    
    UIView *wrap = self.navigationItem.titleView;
    if (!wrap) {
        return;
    }
    for (int i = 1; i <= wrap.subviews.count; i++) {
        UIButton *button = (UIButton *)[wrap viewWithTag:7000+i];
        if (tag == i) {
            [button setTitleColor:DefaultNavigationColor forState:UIControlStateNormal];
            [button setBackgroundColor:[UIColor whiteColor]];
        }else {
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [button setBackgroundColor:DefaultNavigationColor];
        }
    }
    
    if (_centerNavBlock) {
        _centerNavBlock(tag);
    }
}

#pragma mark - Action

- (void)leftButtonClick:(UIButton *)button {

    [[SMViewController sharedSMViewController]showLeftView:YES];
}

- (void)rightButtonClick:(UIButton *)button {

    HomeworkCalendarViewController *calendarView = [[HomeworkCalendarViewController alloc] init];
    calendarView.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:calendarView animated:YES];
}

@end
